package model.tests;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import model.collisions.CollisionCategory;
import model.elements.commands.ElementCommand;
import model.elements.commands.ElementCommandFactory;
import model.elements.states.life.Dead;
import model.elements.states.life.ElementLifeState;
import model.elements.states.movement.MovingDown;
import model.exceptions.CommandFactoryIsNotReady;
import model.map.ElementsMap;

import org.junit.BeforeClass;
import org.junit.Test;

// TODO: Auto-generated Javadoc
/**
 * The Class ElementIsDeadTest.
 */
public class ElementIsDeadTest {
	
	/** The test state. */
	ElementLifeState testState;
	
	/** The test map. */
	static ElementsMap testMap = new ElementsMap(1,1);
	
	/**
	 * Sets the up before class.
	 *
	 * @throws Exception the exception
	 */
	@BeforeClass
	public static void setUpBeforeClass() throws Exception {		
		ElementCommandFactory.setup(testMap);
	}

	/**
	 * Test is alive.
	 *
	 * @throws CommandFactoryIsNotReady the command factory is not ready
	 */
	@Test
	public void testIsAlive() throws CommandFactoryIsNotReady {
		testState = new Dead();		
		assertFalse( testState.isAlive() );
	}

	/**
	 * Test set command.
	 *
	 * @throws CommandFactoryIsNotReady the command factory is not ready
	 */
	@Test
	public void testSetCommand() throws CommandFactoryIsNotReady {		
		testState = new Dead();
		ElementCommand initialCommand = testState.getCommand();
		ElementCommand testCommand = ElementCommandFactory.getElementMove( new MovingDown() );
		testState.setCommand(testCommand);		
		assertTrue( testState.getCommand().equals( initialCommand ) );
	}

	/**
	 * Test get category.
	 *
	 * @throws CommandFactoryIsNotReady the command factory is not ready
	 */
	@Test
	public void testGetCategory() throws CommandFactoryIsNotReady {
		testState = new Dead();		
		assertTrue( testState.getCategory() == CollisionCategory.C_NO_EFFECT );
	}

	/**
	 * Test set category.
	 *
	 * @throws CommandFactoryIsNotReady the command factory is not ready
	 */
	@Test
	public void testSetCategory() throws CommandFactoryIsNotReady {
		testState = new Dead();
		testState.setCategory(CollisionCategory.C_IMPASSABLE);		
		assertTrue( testState.getCategory() == CollisionCategory.C_NO_EFFECT );
	}

}
